/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package py.com.spadons.esmetil.utils;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

/**
 *
 * @author spadons
 */
public class Util implements Serializable {

    private static List<Anho> anhos;
    private static List<Mes> meses;
    private static Anho anhoActual;
    private static Mes mesActual;
    private static Date diaActual;
    private static Date primerDiaMes;
    private static Date ultimoDiaMes;

    public static List<Anho> getAnhos() {
        anhos = new ArrayList<Anho>();
        int desde = getAnhoActual().getAnho() - 3;
        int hasta = getAnhoActual().getAnho() + 1;

        for (int i = desde; i < hasta; i++) {

            Anho a = new Anho(i);
            anhos.add(a);

        }

        return anhos;
    }

    public static List<Mes> getMeses() {


        meses = new ArrayList<Mes>();

        for (int i = 1; i < 13; i++) {
            meses.add(new Mes(i));
        }


        return meses;
    }

    public static Anho getAnhoActual() {


        anhoActual = new Anho(Calendar.getInstance().get(Calendar.YEAR));


        return anhoActual;
    }

    public static Mes getMesActual() {

        mesActual = new Mes(Calendar.getInstance().get(Calendar.MONTH) + 1);

        return mesActual;
    }

    public static Date getDiaActual() {

        Calendar c = Calendar.getInstance();
        c.set(Calendar.HOUR, 0);
        c.set(Calendar.MINUTE, 0);
        c.set(Calendar.SECOND, 0);
        c.set(Calendar.MILLISECOND, 0);
        diaActual = c.getTime();

        return diaActual;
    }

    public static Date getPrimerDiaMes() {
        Calendar c = Calendar.getInstance();
        c.set(Calendar.DAY_OF_MONTH, Calendar.getInstance().getActualMinimum(Calendar.DAY_OF_MONTH));
        c.set(Calendar.HOUR, 0);
        c.set(Calendar.MINUTE, 0);
        c.set(Calendar.SECOND, 0);
        c.set(Calendar.MILLISECOND, 0);
        primerDiaMes = c.getTime();
        return primerDiaMes;
    }

    public static Date getUltimoDiaMes() {
        Calendar c = Calendar.getInstance();
        c.set(Calendar.DAY_OF_MONTH, Calendar.getInstance().getActualMaximum(Calendar.DAY_OF_MONTH));
        c.set(Calendar.HOUR, 23);
        c.set(Calendar.MINUTE, 59);
        c.set(Calendar.SECOND, 59);
        ultimoDiaMes = c.getTime();
        return ultimoDiaMes;
    }
}
